<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style type="text/css">
        #body{
            width: 100px;
            height: 100px;
            background-color: aliceblue;
        }
    </style>
</head>
<body>
    <div>
        <div class="box"></div>
        <button>开关灯</button>
        </div>
    <script>
        var isclicked=false;
        var body=document.body;
        var btn=document.querySelector("button");
        btn.onclick=function(){
            if(!isclicked){
           body.style.backgroundColor="#000000";
           isclicked=true;}
           else{
            body.style.backgroundColor="#FFFFFF"
            isclicked=false;;
           }
        }
    </script>
</body>
</html>